/*-*-C-*-
 * resformat include file for windows
 */

#ifndef __defined_format_h
#define __defined_format_h


/*
 * The block of memory which we will send/receive from the shell consists of
 * a ResourceFileObjectTemplateHeaderRec followed by a WindowTemplateRec
 * followed by String/Message/Relocation tables.
 *
 * This is exactly the form of a window object template in the Resource file.
 */


/* ----------------------- Gadget template headers ----------------------- */

  /* flags */

#define GADGET_FADED         BIT(31)
#define GADGET_ATBACK        BIT(30)

  /* gadget types */

#define GADGET_ACTION_BUTTON     128
#define GADGET_OPTION_BUTTON     192
#define GADGET_LABELLED_BOX      256
#define GADGET_LABEL             320
#define GADGET_RADIO_BUTTON      384
#define GADGET_DISPLAY_FIELD     448
#define GADGET_WRITABLE_FIELD    512
#define GADGET_SLIDER            576
#define GADGET_DRAGGABLE         640
#define GADGET_POPUP             704
#define GADGET_ADJUSTER          768
#define GADGET_NUMBER_RANGE      832
#define GADGET_STRING_SET        896
#define GADGET_WIMP_ICON         960

#define GADGET_UNKNOWN_TYPE     (-1)

  /* template definition */

typedef struct
{
    unsigned int flags;
    short type;
    short size;
    int xmin;
    int ymin;
    int xmax;
    int ymax;
    ComponentID componentID;
    MessageReference helpmessage;
    int maxhelp;
} GadgetTemplateHeaderRec, *GadgetTemplateHeaderPtr;


/* ------------------------ Gadget template bodies ----------------------- */

/* action button */

  /* flags */

#define ACTIONBUTTON_ISDEFAULT           BIT(0)
#define ACTIONBUTTON_ISCANCEL            BIT(1)
#define ACTIONBUTTON_ISLOCAL             BIT(2)
#define ACTIONBUTTON_CLICKSHOWTRANSIENT  BIT(3)

  /* template definition */

typedef struct
{
    MessageReference text;
    int maxtextlen;
    StringReference clickshow;
    int event;
} ActionButtonTemplateRec, *ActionButtonTemplatePtr;


/* option button */

  /* flags */

#define OPTIONBUTTON_GENERATEEVENT  BIT(0)
#define OPTIONBUTTON_SELECTED       BIT(2)

  /* template definition */

typedef struct
{
    MessageReference label;
    int maxlabellen;
    int event;
} OptionButtonTemplateRec, *OptionButtonTemplatePtr;


/* labelled box */

  /* flags */

#define LABELLEDBOX_SPRITE          BIT(0)
#define LABELLEDBOX_SPRITEISFILLED  BIT(1)

  /* template definition */

typedef struct
{
    MessageReference label;        /* could be StringReference also */
} LabelledBoxTemplateRec, *LabelledBoxTemplatePtr;


/* label */

  /* flags */

#define LABEL_NOBOX         BIT(0)

#define LABEL_JUSTIFICATION (BIT(1)|BIT(2))

#define LABEL_LEFTJUSTIFY   0
#define LABEL_RIGHTJUSTIFY  2
#define LABEL_CENTRED       4

  /* template definition */

typedef struct
{
    MessageReference label;
} LabelTemplateRec, *LabelTemplatePtr;


/* radio button */

  /* flags */

#define RADIOBUTTON_GENERATESTATECHANGED   BIT(0)
#define RADIOBUTTON_ON                     BIT(2)

  /* template definition */

typedef struct
{
    int groupnumber;
    MessageReference label;
    int maxlabellen;
    int event;
} RadioButtonTemplateRec, *RadioButtonTemplatePtr;


/* display field */

  /* flags */

#define DISPLAYFIELD_GENERATEVALUECHANGED  BIT(0)

#define DISPLAYFIELD_JUSTIFICATION         (BIT(1)|BIT(2))

#define DISPLAYFIELD_LEFTJUSTIFY           0
#define DISPLAYFIELD_RIGHTJUSTIFY          2
#define DISPLAYFIELD_CENTRED               4

  /* template definition */

typedef struct
{
    MessageReference text;
    int maxtextlen;
} DisplayFieldTemplateRec, *DisplayFieldTemplatePtr;


/* writable field */

  /* flags */

#define WRITABLEFIELD_GENERATEVALUECHANGED  BIT(0)

#define WRITABLEFIELD_JUSTIFICATION         (BIT(2)|BIT(3))

#define WRITABLEFIELD_LEFTJUSTIFY           0
#define WRITABLEFIELD_RIGHTJUSTIFY          4
#define WRITABLEFIELD_CENTRED               8

#define WRITABLEFIELD_PASSWORD              BIT(4)

  /* template definition */

typedef struct
{
    MessageReference text;
    int maxtextlen;
    MessageReference allowable;
    int maxallowablelen ;
    ComponentID before;
    ComponentID after;
} WritableFieldTemplateRec, *WritableFieldTemplatePtr;


/* slider */

  /* flags */

#define SLIDER_GENERATEVALUECHANGEDOPTION     (BIT(0)|BIT(1))

#define SLIDER_GENERATEVALUECHANGEDNEVER         0
#define SLIDER_GENERATEVALUECHANGEDENDOFDRAG     1
    /* SLIDER_GENERATEVALUECHANGEDOPTION = 2 doesn't seem useful */
#define SLIDER_GENERATEVALUECHANGEDCONTINUOUSLY  3

#define SLIDER_VERTICAL                       BIT(3)
#define SLIDER_DRAGGABLE                      BIT(4)

#define SLIDER_BARCOLOUR         (BIT(12)|BIT(13)|BIT(14)|BIT(15))
#define SLIDER_BARCOLOURSHIFT                   12
#define SLIDER_BACKCOLOUR        (BIT(16)|BIT(17)|BIT(18)|BIT(19))
#define SLIDER_BACKCOLOURSHIFT                  16

  /* template definition */

typedef struct
{
    int lowerbound;
    int upperbound;
    int stepsize;
    int initialvalue;
} SliderTemplateRec, *SliderTemplatePtr;


/* draggable */

  /* flags */

#define DRAGGABLE_GENERATEDRAGSTARTED         BIT(0)
#define DRAGGABLE_SPRITE                      BIT(1)
#define DRAGGABLE_TEXT                        BIT(2)

#define DRAGGABLE_TYPE                        (BIT(3)|BIT(4)|BIT(5))

#define DRAGGABLE_DRAG                         0
#define DRAGGABLE_CLICKDRAG                    8
#define DRAGGABLE_DOUBLECLICKDRAG             16

#define DRAGGABLE_USETOOLBOXIDS               BIT(6)
#define DRAGGABLE_HASDROPSHADOW               BIT(7)
#define DRAGGABLE_NOTDITHERED                 BIT(8)

  /* template definition */

typedef struct
{
    MessageReference text;
    int maxtextlen;
    StringReference sprite;
    int maxspritelen;
} DraggableTemplateRec, *DraggableTemplatePtr;


/* popup */

  /* flags */

#define POPUP_GENERATEABOUTTOBESHOWN   BIT(0)

  /* template definition */

typedef struct
{
    StringReference menu;
} PopUpTemplateRec, *PopUpTemplatePtr;


/* adjuster */

  /* flags */

#define ADJUSTER_ADJUSTMENT     BIT(0)

#define ADJUSTER_DECREMENT      0
#define ADJUSTER_INCREMENT      1

#define ADJUSTER_ORIENTATION    BIT(1)

#define ADJUSTER_LEFTRIGHT      0
#define ADJUSTER_UPDOWN         2

  /* template definition */

typedef struct
{
    int dummy;
} AdjusterTemplateRec, *AdjusterTemplatePtr;


/* number range */

  /* flags */

#define NUMBERRANGE_GENERATEVALUECHANGED      BIT(0)
#define NUMBERRANGE_WRITABLE                  BIT(2)
#define NUMBERRANGE_NONUMERICALDISPLAY        BIT(3)
#define NUMBERRANGE_ADJUSTERS                 BIT(4)

#define NUMBERRANGE_SLIDERTYPE                (BIT(5)|BIT(6)|BIT(7))

#define NUMBERRANGE_NOSLIDER                   0
#define NUMBERRANGE_SLIDERRIGHT               32
#define NUMBERRANGE_SLIDERLEFT                64

#define NUMBERRANGE_JUSTIFICATION             (BIT(8)|BIT(9))

#define NUMBERRANGE_LEFTJUSTIFY                0
#define NUMBERRANGE_RIGHTJUSTIFY             256
#define NUMBERRANGE_CENTRED                  512

#define NUMBERRANGE_SLIDERBARCOLOUR      (BIT(12)|BIT(13)|BIT(14)|BIT(15))
#define NUMBERRANGE_SLIDERBARCOLOURSHIFT      12

#define NUMBERRANGE_SLIDERBACKCOLOUR     (BIT(16)|BIT(17)|BIT(18)|BIT(19))
#define NUMBERRANGE_SLIDERBACKCOLOURSHIFT     16

  /* template definition */

typedef struct
{
    int lowerbound;
    int upperbound;
    int stepsize;
    int initialvalue;
    int precision;
    ComponentID before;
    ComponentID after;
    int displaylength;
} NumberRangeTemplateRec, *NumberRangeTemplatePtr;


/* string set */

  /* flags */

#define STRINGSET_GENERATEVALUECHANGED      BIT(0)
#define STRINGSET_WRITABLE                  BIT(2)
#define STRINGSET_GENERATEABOUTTOBESHOWN    BIT(3)
#define STRINGSET_NODISPLAY                 BIT(4)

#define STRINGSET_JUSTIFICATION             (BIT(5)|BIT(6))

#define STRINGSET_LEFTJUSTIFY                0
#define STRINGSET_RIGHTJUSTIFY              32
#define STRINGSET_CENTRED                   64

  /* template definition */

typedef struct
{
    MessageReference stringset;
    MessageReference title;
    MessageReference initialselectedstring;
    int maxselectedstringlen;
    MessageReference allowable;
    int maxallowablelen;
    ComponentID before;
    ComponentID after;
} StringSetTemplateRec, *StringSetTemplatePtr;


/* wimp icon */

  /* flags */

#define WIMPICON_TASKSPRITEAREA             BIT(0)
#define WIMPICON_RETURNMENUCLICKS           BIT(1)

  /* template definition */

typedef struct
{
    unsigned int buttonflags;
    MessageReference value;
    int maxvalue;
    StringReference validation;
    int maxvalidation;
} WimpIconTemplateRec, *WimpIconTemplatePtr;


/* --------------------------- Gadget templates -------------------------- */

typedef union
{
    ActionButtonTemplateRec actionbutton;
    OptionButtonTemplateRec optionbutton;
    LabelledBoxTemplateRec labelledbox;
    LabelTemplateRec label;
    RadioButtonTemplateRec radiobutton;
    DisplayFieldTemplateRec displayfield;
    WritableFieldTemplateRec writablefield;
    SliderTemplateRec slider;
    DraggableTemplateRec draggable;
    PopUpTemplateRec popup;
    AdjusterTemplateRec adjuster;
    NumberRangeTemplateRec numberrange;
    StringSetTemplateRec stringset;
    WimpIconTemplateRec wimpicon;
} GadgetTemplateBodyRec, *GadgetTemplateBodyPtr;


typedef struct
{
    GadgetTemplateHeaderRec hdr;
    GadgetTemplateBodyRec body;
} GadgetTemplateRec, *GadgetTemplatePtr;


/* --------------------- Keyboard shortcut templates --------------------- */

  /* flags */

#define KEYBOARDSHORTCUT_SHOWASTRANSIENT    BIT(0)

  /* template definition */

typedef struct
{
    unsigned int flags;
    int wimpkeycode;
    int keyevent;
    StringReference keyshow;
} KeyBoardShortcutTemplateRec, *KeyBoardShortcutTemplatePtr;


/* --------------------------- Window templates -------------------------- */

  /* flags */

#define WINDOW_GENERATEABOUTTOBESHOWN        BIT(0)
#define WINDOW_AUTOOPEN                      BIT(1)
#define WINDOW_AUTOCLOSE                     BIT(2)
#define WINDOW_GENERATEHASBEENHIDDEN         BIT(3)
#define WINDOW_ISTOOLBAR                     BIT(4)

  /* template definitions */

typedef struct
{
    int visxmin;
    int visymin;
    int visxmax;
    int visymax;
    int scrollx;
    int scrolly;
    int behind;
    unsigned int windowflags;
    char titlefore;
    char titleback;
    char workfore;
    char workback;
    char scrollouter;
    char scrollinner;
    char titleinputfocus;
    char filler;
    int workxmin;
    int workymin;
    int workxmax;
    int workymax;
    unsigned int titleflags;
    int buttontype;
    SpriteAreaReference spritearea;
    char minwidth[2];
    char minheight[2];
    MessageReference titletext;
    StringReference titlevalidation;
    int titlebuflen;
    int numicons;
} WindowWimpTemplateRec, *WindowWimpTemplatePtr;

typedef struct
{
    unsigned int flags;
    MessageReference helpmessage;
    int maxhelp;
    StringReference pointershape;
    int maxpointershape;
    int pointerxhot;
    int pointeryhot;
    StringReference menu;
    int numkeyboardshortcuts;
    Offset keyboardshortcuts;
    int numgadgets;
    Offset gadgets;
    ComponentID defaultfocus;
    int showevent;
    int hideevent;
    StringReference toolbaribl;
    StringReference toolbaritl;
    StringReference toolbarebl;
    StringReference toolbaretl;
    WindowWimpTemplateRec window;

    /* shortcuts and gadgets follow */

} WindowTemplateRec, *WindowTemplatePtr;

/* special values for defaultfocus field */
#define  DEFAULTFOCUS_NONE        (-1)
#define  DEFAULTFOCUS_INVISIBLE   (-2)


/* ----------------------------------------------------------------------- */

#endif
